from django.shortcuts import render
from feed.models import Feed, Recipe, UserFeed

from django.contrib.auth.decorators import login_required
from django.db.models import Q

# Create your views here.
def home_view(request):
    return render(request, 'home.html', { 'pagetitle': "kFeeder"})


@login_required(login_url='/login')
def feed_view(request):
    availfeeds = Feed.objects.filter(Q(public=True, available=True) | Q(user=request.user))
    return render(request, 'feed.html', {'pagetitle': "My Feed", 'availfeeds': availfeeds})

